home *** CD-ROM | disk | FTP | other *** search
Text File | 1992-04-08 | 6.2 KB | 181 lines | [TEXT/CCL2] |
- #|
- build-and-run-mini-app.lisp
-
- To compile and load and start the Mini-Application, load this file.
-
- For further info, see files "About Mini-App" and "Instructions".
-
-
- Portions copyright ©1989-1992 Apple Computer, Inc
-
- Change History.
- 03-12-92 slm Updated file header comments.
- 03-06-92 slm Deliberately and shamelessly lifted most of the IFT's
- "ccl:Interface Tools:make-ift.lisp".
- This is a tutorial; we define no "package".
-
-
- A simple defsystem.
-
- The defsystem defines the following:
- - dependencies between files (what must compile or load before what).
- In this case, dependencies are enforced by a 2-level strategy:
- 1. Procedurally by partitioning files into 4 groups (coarse).
- The groups are loaded in a fixed order.
- 2. Lexically by ordering files within each group (fine).
- The files within each group are loaded in forward order.
- - "support" files - macros, patches and low-level code
- - "module" files - These are libraries that at the end of
- their source files call #'provide with their colloquial name.
- See docs on #'provide and *modules*.
- - "core" files - Menus, palettes, behavior, etc
- - "application" files - Palette item instances, specific behavior.
-
- To better understand this draw a call graph, starting with load-app.
-
- More sophisticated dependencies, such as what other files must be
- recompiled if a certain file is recompiled, are not implemented.
- |#
-
- (unless (and
- (equalp "Mini-Application"
- (car (last (butlast (pathname-directory
- (translate-logical-pathname "ccl:mini-app;"))))))
- (equalp "Program"
- (car (last (pathname-directory
- (translate-logical-pathname "ccl:mini-app;"))))))
- (ccl::add-logical-pathname-translation
- "ccl" '("mini-app;**;*.*" "ccl:Mini-Application;Program;*.*")))
-
- (defparameter *app-support-files*
- '("ccl:mini-app;open-all-text-files"))
-
- (defparameter *app-modules* '((quickdraw . "ccl:library;QuickDraw")))
-
- (defparameter *app-core-files*
- '("ccl:mini-app;globals"
- "ccl:mini-app;utilities"
- "ccl:mini-app;draw-dialog-class"
- "ccl:mini-app;menus"
- "ccl:mini-app;palette-class"
- "ccl:mini-app;draw-item-class"
- "ccl:mini-app;default-handlers" ; for DRAW-DIALOG windows & DRAW-ITEM objects
- "ccl:mini-app;start-application"))
-
- (defparameter *app-files* '("ccl:mini-app;mini-app-example"))
-
- (defvar *loaded-app-files* '() "Keep track of files that are loaded.")
-
- (defun compile-if-changed (file always)
- "Compiles file if not compiled, if changed, or if always is t."
- (let* ((source (merge-pathnames file ".lisp"))
- (fasl (merge-pathnames file ".fasl")))
- (unless (probe-file source)
- (error "file not found: ~s" file))
- (when (or always
- (not (probe-file fasl))
- (< (file-write-date fasl)
- (file-write-date source)))
- (compile-file source :output-file fasl :verbose t))))
-
- (defun load-if-changed (file always)
- "Loads fasl file if not loaded or if changed, compiling first if necessary."
- (compile-if-changed file nil)
- (let* ((fasl (merge-pathnames file ".fasl"))
- (date (file-write-date fasl))
- (last-load (assoc file *loaded-app-files* :test #'equalp)))
- (when (or always
- (not last-load)
- (< (cdr last-load)
- date))
- (load fasl :verbose t)
- (if last-load
- (setf (cdr last-load) date)
- (push (cons file date) *loaded-app-files*)))))
-
- (defun load-app-support ()
- "Loads support fasl files, compiling first if necessary."
- (dolist (file *app-support-files*)
- (load-if-changed file nil)))
-
- (defun load-app-modules ()
- "Loads library (module) fasl files, compiling first if necessary."
- (dolist (module *app-modules*)
- (destructuring-bind (module-name . file) module
- (when (or (not (member module-name *modules* :test 'string-equal))
- (compile-if-changed file nil))
- (load-if-changed file nil)))))
-
- (defun load-app-core-files ()
- "Loads core files, if not loaded or if changed."
- (dolist (file *app-core-files*)
- (load-if-changed file nil)))
-
- (defun load-app-files ()
- "Loads application files, if not loaded or if changed."
- (dolist (file *app-files*)
- (load-if-changed file nil)))
-
- (defun load-app ()
- "Loads support, module and application files, if not loaded or if changed."
- (with-compilation-unit ()
- (load-app-support))
- (with-compilation-unit ()
- (load-app-modules)) ;modules are compiled if changed or not yet compiled
- (with-compilation-unit ()
- (load-app-core-files))
- (with-compilation-unit ()
- (load-app-files))
- (pushnew :mini-app *features*))
-
-
- ;;; __________________________________________________________________
- ;;; START MINI APPLICATION
-
- ;;; Start up our little application.
- ;;;
-
- (progn
- (load-app)
- (start-application)) ;in ccl:mini-app;start-application
-
-
- ;;; Record this application as loaded (Common Lisp bookkeeping)
- ;;;
- (provide :mini-application)
-
-
- #|
-
- If you really want to compile the Mini-Application without loading it
- (warning: this wasn't tested, because I don't use it):
-
- ;(compile-app) ;compiles any files that need compiling
- ;(compile-app T) ;compiles all files unconditionally
-
- (defun compile-core-files (&optional always)
- "Compiles core files, if changed or if always is t."
- (dolist (file *app-core-files*)
- (compile-if-changed file always)))
-
- (defun compile-app-files (&optional always)
- "Compiles application files, if changed or if always is t."
- (dolist (file *app-files*)
- (compile-if-changed file always)))
-
- (defun compile-app (&optional always)
- "Loads support and module files, and compiles application files,
- if changed or if always is t."
- (with-compilation-unit ()
- (load-app-support)) ;it is necessary to load the support files
- (with-compilation-unit ()
- (load-app-modules)) ;it is necessary to load the library files
- (with-compilation-unit ()
- (compile-core-files always))
- (with-compilation-unit ()
- (compile-app-files always)))
- |#
-
- ;end of file build-and-run-mini-app.lisp
- ;------------------------------------------------
-